At the year’s midpoint, San Jose is looking at a homicide rate that would be among the highest in city history, while Oakland is looking at a rate so low it hasn’t been seen since before the crack epidemic. But what do those numbers really say about crime in the two cities?

Few would argue that Oakland has become as safe as San Jose, even though their 2016 homicide totals are almost the same. Homicide numbers don’t always align with how dangerous a city really is, often fluctuating with the randomness of a hastily fired bullet or how quickly a victim gets to the deft hands of a trauma surgeon.

But another set of numbers seems to confirm the perception that Oakland is doing a better job of combating violent crime than it has in recent years, while the opposite is true in San Jose. Violent crime is down 10 percent in Oakland in the first half of the year compared with the same period in 2015; violent crime has risen by 15 percent in San Jose.

Gritty Oakland is still far more violent than mostly suburban San Jose: According to the latest complete FBI data, the East Bay’s largest city has a violent crime rate of 16.85 incidents per 1,000 residents, while San Jose, which at 1 million residents has more than double the population, has a violent crime rate of 3.21 per 1,000 residents. But Oakland, at least, is headed in a good direction.

Oakland officials say the downward trend in homicides and violent crime can be attributed to its Ceasefire program, where Oakland police have engaged residents to help identify and arrest people disproportionately responsible for the back-and-forth violence that plagues certain neighborhoods.

“Violent crime isn’t down by accident,” said Capt. Ersie Joyner, who heads the program. “It’s down by design.”

With 28 homicides so far in 2016 through June, Oakland is on pace to see its lowest annual total in nearly half a century; homicides have numbered more than 80 since 1968. Since Friday, there have been threemore homicides in the city. Compared with the same point last year, homicides are down 30 percent and shootings have decreased 15 percent.

“I’d almost call it a relentless focus on reducing crime in Oakland,” acting Assistant Chief David Downing said. “The one thing I’ve learned when the crime goes down we are going to take credit for it, absolutely. Because when it goes back up we are going to get that, too.”

San Jose police and the city’s lauded Mayor’s Gang Prevention Task Force have used similarly focused policing to halve the number of gang-motivated killings compared with four years ago.

Of the city’s 25 homicides through June — on pace for the highest total in 25 years — only about five are suspected to be gang related. That gang tally could rise, however, as Tuesday’s double-fatal shooting near San Jose State is being investigated for potential gang motives, according to a source familiar with the investigation.

The homicide total is particularly pronounced because it came after a down year for the city. In 2015, the city recorded 10 homicides by midyear, punctuated by an 80-day stretch when no killings were recorded, though 20 were recorded in the second half of the year.

But aggravated assaults in 2015 were still level with the past five years, meaning that fewer people were killed, but about the same number were victims of some sort of attack.

Now, in the first six months of this year, aggravated assaults are up 20 percent in San Jose.

Police Chief Eddie Garcia and other city officials say they are troubled by the rise in violent crime, but argue that it has been exacerbated by a 30 percent decrease in the number of police staff over the past eight years.

“Our officers are doing the best they can” to keep up with the increase in violence, Garcia said. “It’s a city of a million people. We’re coming up with ways every day to maintain ourselves as one of the safest large cities in the country.”

Garcia said that even amid the violent crime increase are notable victories, such as keeping gang violence in check.

“We’re going out in areas that we know have more propensity for violence, areas we feel officers will be more efficient in being more proactive and more visible,” he said.

Mario Maciel, superintendent of the city’s gang-prevention task force and one of its foremost gang experts, said he aims to continue the work curbing gang activity in the city in part through San Jose Works, a youth-employment initiative that aims to keep at-risk youth productive during the summer.

“We’re going to give a thousand kids jobs and the city continues to be poised to continue to combat this nationwide dilemma of youth violence,” he said. “We’re proud that even in the tragedies we have, which are way too many, we are having an impact on those most marginalized. Our commitment here is to keep the pain as small as possible.”

The midyear homicide figures in San Jose and Oakland also reveal other unusual distinctions. Oakland police Lt. Roland Holmgren noted a rise in “relationship-based” killings, pointing to multiple cases that involve a suspect who knew a victim or involved fights over women and drugs.

In San Jose, more than a third of its 25 homicides so far this year involved victims who had a domestic or family relationship with their alleged killers, and were not easily preventable by police. That’s a higher percentage than in recent years. Those cases include three people suspected of murdering their parents, a man who allegedly sexually assaulted a toddler, and a suspect accused of brutally murdering a co-worker.

In Oakland, all but one of the homicides in the first half of the year involved guns; the other was a stabbing. Of the 25 homicides in San Jose during the same time period, 14 were shootings, five were stabbings and two were blunt-force attacks. One suspect allegedly used a car to kill. One allegedly killed a toddler during a sexual assault. And the method of one homicide other has not been publicly disclosed.

The majority of homicide victims in Oakland were black; in San Jose, the majority were Latino.

Over half of the killings in Oakland occurred in East Oakland, though it should be noted that is the largest portion of the city.

Killings in San Jose, which once used to be concentrated on the East Side, are now distributed fairly evenly throughout the city.

Staff writer Matthias Gafni contributed to this report. Contact Robert Salonga at 408-920-5002. Follow him at Twitter.com/robertsalonga.